package cn.alpha.intell.rbtlib.wifi.dlalog;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import cn.alpha.intell.rbtlib.R;
import cn.alpha.intell.rbtlib.wifi.adapter.AddWiFiItemAdapter;


/**
 * Created by huangzhiqin on 2016/10/8.
 */
public class AddWiFiAdapter extends BaseAdapter{
    private LayoutInflater inflater;
    private Context context;
    private List<String> list;

    public AddWiFiAdapter(Context context) {
        this.context = context;
        inflater=LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        EditText editName;
        final ListView listView;
        EditText editPaw;
        ImageView downImageView;
       final TextView type;
            View view = inflater.inflate(R.layout.add_wifi_item, parent, false);
            downImageView= (ImageView) view.findViewById(R.id.add_wifi_down);
            listView=(ListView)view.findViewById(R.id.add_wifi_item_listview);
            type=(TextView)view.findViewById(R.id.add_wifi_tv);
            downImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final AddWiFiItemAdapter addWiFiItemAdapter=new AddWiFiItemAdapter(context);
                addWiFiItemAdapter.setData(list);
                listView.setAdapter(addWiFiItemAdapter);
                listView.setVisibility(View.VISIBLE);
            }
        });
        list=new ArrayList<>();
        list.add(0,"无");
        list.add(1,"WEP");
        list.add(2,"WPA/WPA2 PSK");
        list.add(3,"802.1x EAP");
        list.add(4,"WAPI PSK");

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.e("AddWiFiAdapter","==>wifi item" +list.get(position));
                listView.setVisibility(View.GONE);
                type.setText(list.get(position));

            }
        });

        return view;
    }

  /*class AddWifiHolder{


  }*/
}
